package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.DayTarget;
import com.genexususa.eo.bing.CampaignManagementServiceClasses.DayTargetBid;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class GxDayTarget extends DayTarget {
    public GxDayTarget(Element element) {
        NodeList bidsNode = element.getElementsByTagName("DayTargetBidCollection");
        if (bidsNode.getLength() > 0) {
            NodeList dayTargetBidNode = ((Element)bidsNode.item(0)).getElementsByTagName("DayTargetBid");
            DayTargetBid[] dayTargetBids = new DayTargetBid[dayTargetBidNode.getLength()];
            for (int temp = 0; temp < dayTargetBidNode.getLength(); temp++) {
                dayTargetBids[temp] = new GxDayTargetBid((Element)dayTargetBidNode.item(temp));
            }
            this.setBids(dayTargetBids);
        }
        if (element.getElementsByTagName("TargetAllDays").getLength() > 0 &&
            element.getElementsByTagName("TargetAllDays").item(0).getChildNodes().getLength() > 0) {
            this.setTargetAllDays(Boolean.valueOf(element.getElementsByTagName("TargetAllDays").item(0).getChildNodes().item(0).getNodeValue()));
        }
    }
}
